package org.lc.stk.web.dto.majorcengci;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "专业层次关联查询条件")
public class MajorCengciQuery {
    
    @Schema(description = "专业ID", example = "1")
    private Integer majorId;
    
    @Schema(description = "专业编码(模糊匹配)", example = "CS")
    private String majorCode;
    
    @Schema(description = "专业名称(模糊匹配)", example = "计算机")
    private String majorName;
    
    @Schema(description = "培养层次ID", example = "1")
    private Integer cengciId;
    
    @Schema(description = "培养层次编码(模糊匹配)", example = "B")
    private String cengciCode;
    
    @Schema(description = "培养层次名称(模糊匹配)", example = "本")
    private String cengciName;
    
    @Schema(description = "排序字段(orderNum/createTime/updateTime)", example = "orderNum")
    private String sortBy = "orderNum";
    
    @Schema(description = "排序方式(asc/desc)", example = "asc")
    private String sortDirection = "asc";

    public Integer getMajorId() {
        return majorId;
    }

    public void setMajorId(Integer majorId) {
        this.majorId = majorId;
    }

    public String getMajorCode() {
        return majorCode;
    }

    public void setMajorCode(String majorCode) {
        this.majorCode = majorCode;
    }

    public String getMajorName() {
        return majorName;
    }

    public void setMajorName(String majorName) {
        this.majorName = majorName;
    }

    public Integer getCengciId() {
        return cengciId;
    }

    public void setCengciId(Integer cengciId) {
        this.cengciId = cengciId;
    }

    public String getCengciCode() {
        return cengciCode;
    }

    public void setCengciCode(String cengciCode) {
        this.cengciCode = cengciCode;
    }

    public String getCengciName() {
        return cengciName;
    }

    public void setCengciName(String cengciName) {
        this.cengciName = cengciName;
    }

    public String getSortBy() {
        return sortBy;
    }

    public void setSortBy(String sortBy) {
        // 验证排序字段
        if (sortBy != null && !isValidSortField(sortBy)) {
            throw new IllegalArgumentException("Invalid sort field: " + sortBy);
        }
        this.sortBy = sortBy;
    }

    public String getSortDirection() {
        return sortDirection;
    }

    public void setSortDirection(String sortDirection) {
        // 验证排序方向
        if (sortDirection != null && 
            !sortDirection.equalsIgnoreCase("asc") && 
            !sortDirection.equalsIgnoreCase("desc")) {
            throw new IllegalArgumentException("Sort direction must be either 'asc' or 'desc'");
        }
        this.sortDirection = sortDirection.toLowerCase();
    }

    private boolean isValidSortField(String field) {
        return field.equals("orderNum") || 
               field.equals("createTime") || 
               field.equals("updateTime");
    }
}